package cn.com.yang.datastruct.graph;
/**
 * 广度优先搜索-队列 FIFO
 * TODO
 * @author yangyijin
 * @since 2024年2月6日-下午5:49:46
 */
public class Queue {
	private final int SIZE=20;
	private int[] queueArray;
	private int front;
	private int rear;
	public Queue() {
		this.queueArray = new int[SIZE];
		this.front = 0;
		this.rear = -1;
	}
	public void insert(int i) {
		if(rear==SIZE-1) {
			rear=-1;
		}
		queueArray[++rear]=i;
	}
	//删除的是头部元素
	//[1,2,3]=>[2,3]
	public int remove() {
		int temp = queueArray[front++];
		if(front==SIZE) {
			front=0;
		}
		return temp;
	}
	public boolean isEmpty() {
		return rear+1==front || front+SIZE-1==rear;
	}
}
